using System.Diagnostics;

namespace Infinity.Common.Logger
{
	/// <summary>
	/// Logger class for System.Diagnostics.Debug class
	/// </summary>
	public class DebugLogger : TimeLoggerBase
	{
		private DebugLogger()
		{
		}

		private static DebugLogger _Instance;

		public override void Flush()
		{
			Debug.Flush();
		}

		public override void Alert(string text)
		{
			Write("ALERT: ");
			WriteLine(text, false);
		}

		public override void Info(string text)
		{
			Write("INFO: ");
			WriteLine(text, false);
		}

		public override void Warning(string text)
		{
			Write("WARNING: ");
			WriteLine(text, false);
		}

		public override void Error(string text)
		{
			Write("ERROR: ");
			WriteLine(text, false);
		}

		protected override void Write(string text, bool logTime)
		{
			Debug.Write(logTime ?ToLogTime(text) : text);
		}

		public static DebugLogger Instance
		{
			get
			{
				if (_Instance == null)
					_Instance = new DebugLogger();
				return _Instance;
			}
		}
	}
}